home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / utilboot10.s < prev    next >
Text File  |  1998-11-06  |  11KB  |  453 lines

  1. *************************************************************************
  2. *              uTiLiTy bOoT                v1.0    *
  3. *-----------------------------------------------------------------------*
  4. * -> FastVBR (only if 68010+ and FAST ram found)            *
  5. * -> Mouse Acceleration                         *
  6. * -> AmigaDOS PAL window (for PAL users like me)            *
  7. *                                    *
  8. *     >>> Very useful (I think) for floppy only Amigas! <<<        *
  9. *-----------------------------------------------------------------------*
  10. *            -oOo- Instructions -oOo-            *
  11. *-----------------------------------------------------------------------*
  12. * - Hold LEFT mousebut. during boot to disable Mouse Accel. feature    *
  13. * - Hold RIGHT mousebut. during boot to disable    PAL Window feature    *
  14. * - Press LEFT ALT+LEFT AMIGA+F1 .. F8 keys to set Mouse Accel. Factor    *
  15. *   anytime after the system has booted. (I know, it may conflict    *
  16. *   with other Hotkeys. But you can change this here.)            *
  17. *-----------------------------------------------------------------------*
  18. * Assembled using Asm-One 1.20                        *
  19. * (Trash'm-one 1.6 won't accept 68010+ opcodes)                *
  20. * Should work with all Kickstarts. Tested under 1.3, 2.04 and 3.1    *
  21. * on my good old A500 (68010, 4meg FAST, 1meg CHIP, 1.5 fake FAST)    *
  22. *-----------------------------------------------------------------------*
  23. * Coded by:            Frédéric BASSALER            *
  24. *                La Serre                *
  25. *                19500 Collonges                *
  26. *                France                    *
  27. *                                    *
  28. *                fbas@club-internet.fr            *
  29. *                                    *
  30. * Send remarks, suggestions, flames, hellos, donations(?!)        *
  31. *************************************************************************
  32.  
  33.     Incdir    ASM:/Include/
  34.     Include equ.s
  35.     include exec/types.i
  36.     include exec/interrupts.i
  37.     include intuition/intuition.i
  38.  
  39. Width        =    320    ;screen with
  40. Height        =    256    ;screen height
  41. BytesPerRow    =    Width/8
  42.  
  43.     rsreset
  44. handler     rs.l    1
  45. handlercode    rs.l    1
  46. newvector    rs.l    1
  47. olddma        rs.w    1
  48. inputio     rs.b    48
  49. msgport        rs.b    34
  50. planes        rs.b    (BytesPerRow*Height)
  51. mycop        rs.b    64    ;large enough to contain the coplist data
  52. VARSIZE     rs.w    0
  53.  
  54.  
  55. DEFXFACT    =    8    ;default mouse acceleration factor
  56. DLAY        =    100    ;delay value in 1/50 secs
  57.  
  58. ;DBUG=0 ;enable it for debugging
  59.  
  60. ******** Bootblock data
  61. Start:
  62.     IFND    DBUG
  63.     dc.b    "DOS"        ;disk type: DOS
  64.     dc.b    0        ;0 is OFS, 1 is FFS (OS 2+ only)
  65.     dc.l    0        ;checksum
  66.     dc.l    $370        ;root block ($370 = 880)
  67.     ENDC
  68.  
  69. ******** Our bootcode starts here
  70. Main:
  71.     movem.l d0-a6,-(sp)
  72.  
  73.     IFD    DBUG
  74.     move.l    4.w,a6
  75.     ENDC
  76.  
  77. ; transfer the Vector Base Register (VBR) to FAST ram to speed up the system!
  78. ; will only work with MC68010+ processors and if you have some (real) FAST ram
  79.  
  80. ;this routine was inspired by Frank Wille's Vbr.s (PhxAss package)
  81.  
  82. FastVBR:
  83. ;test if we have a 68010 or higher
  84.     btst    #0,296+1(a6)        ;execbase->AttnFlags
  85.     beq.s    .I_only_found_a_68000
  86.  
  87. ;    move.l    #$400,d0    ;VBR_SIZE=$400 (1024 bytes)
  88.     moveq    #$40,d0        ;this two lines are equivalent to
  89.     lsl    #4,d0        ;'move.l #$400,d0', but they save 2 bytes!
  90.  
  91.     moveq    #4!1,d1        ;memf_fast!memf_public
  92.     jsr    AllocMem(a6)
  93.     tst.l    d0
  94.     beq.s    .no_fast
  95.     move.l    d0,a3
  96.     move.l    a3,a4
  97.  
  98.     suba.l    a0,a0
  99.     move    #($400/4)-1,d0
  100. .cop    move.l    (a0)+,(a3)+
  101.     dbf    d0,.cop
  102.  
  103.     lea    put_vbr(pc),a5
  104.     jsr    -30(a6)        ;Supervisor()
  105.  
  106.     cmp    #36,20(a6)    ;test execbase version
  107.     blt.s    .old_OS
  108.     jsr    CacheClearU(a6)    ;only under OS 2.0+
  109. .old_OS
  110. .no_fast
  111. .I_only_found_a_68000
  112.  
  113.  
  114. ; alloc memory for global vars
  115.     move.l    #VARSIZE,d0
  116.     move.l    #$10002,d1    ;chip!clear (the copperlist must be in CHIP)
  117.     jsr    AllocMem(a6)
  118.     move.l    d0,a5
  119. ; alloc buffer for the new input-handler structure
  120.     IFND    DBUG
  121.     moveq    #IS_SIZE,d0
  122. ;    move.l    #$10000,d1
  123.     moveq    #1,d1        ;this two lines equal to 'move.l #$10000,d1'
  124.     swap    d1        ;but the produced code is smaller!
  125.     jsr    AllocMem(a6)
  126.     move.l    d0,handler(a5)
  127. ; alloc buffer for the input-handler code (is_code)
  128.     moveq    #codesize,d0
  129.     moveq    #$1,d1        ;MEMF_PUBLIC
  130.     jsr    AllocMem(a6)
  131.     move.l    d0,handlercode(a5)
  132.     ENDC
  133.  
  134. ******** copy RAW gfx data into bitplane
  135. X=100    ;x coordinates of picture to appear
  136. Y=100    ;y coords.
  137.  
  138.     lea    [planes+(Y*BytesPerRow)+(X/8)](a5),a2    ;bitplane addr
  139.     lea    rawgfx(pc),a0    ;source: raw gfx data
  140.     moveq    #5-1,d7     ;# lines
  141. .cop0
  142.     move.l    a2,a1
  143.     moveq    #14-1,d0    ;# bytes per line = datasize/# lines
  144. .cop    move.b    (a0)+,(a1)+
  145.     dbf    d0,.cop
  146.     lea    BytesPerRow(a2),a2    ;next line
  147.     dbf    d7,.cop0
  148.  
  149.     lea    $dff000,a4
  150.     move    2(a4),olddma(a5)    ;save old dma
  151.     or    #$8400,olddma(a5)
  152.     move    #$7fff,$96(a4)        ;dma off
  153.     lea    coplist(pc),a1
  154. ; set bitplane address in copperlist
  155.     lea    planes(a5),a2
  156.     move.l    a2,d0
  157.     move    d0,lo1-coplist(a1)
  158.     swap    d0
  159.     move    d0,hi1-coplist(a1)
  160. ; copy copperlist into (CHIP MEM) buffer
  161.     lea    mycop(a5),a2
  162.     move.l    a2,$80(a4)    ;new coplist adr
  163.  
  164.     moveq    #(copsize/4)-1,d0
  165. .copy    move.l    (a1)+,(a2)+
  166.     dbf    d0,.copy
  167.  
  168.     clr    $88(a4)     ;start new coplist
  169.     move    #%1000001111000000,$96(a4)    ;new dma
  170. ; put 1 here ----------^ (instead of 0) if you want the BLITTER_NASTY feature
  171.  
  172. ******** Wait for some delay... so we can see the little logo!
  173.     IFD    DBUG
  174. .wd    btst    #6,$bfe001    ;test left mouse button
  175.     bne.s    .wd
  176.     bra    closeall
  177.     ELSE
  178.  
  179. ;    move.l    4.w,a6
  180.     move.l    $9c(a6),a6    ;GfxBase in A6 (little hack!)
  181.                 ;seems to work with all kickstarts!
  182.     moveq    #DLAY,d7    ;number of 1/50 secs to wait for
  183. .wait    jsr    WaitTOF(a6)    ;wait VBL
  184.     dbf    d7,.wait
  185.     ENDC
  186.  
  187. ******* Hold left mousebutton while booting to disable Mouse Acceleration
  188.     btst    #6,$bfe001    ;test left mouse button
  189.     beq.s    PAL_Win
  190.  
  191. ******* Create a new message port and open input.device
  192.     lea    msgport(a5),a1
  193.     move.l    a1,d7
  194.     move.l    4.w,a6            ;execbase in A6
  195.     move.l    276(a6),$10(a1)     ;execbase->ThisTask
  196.     jsr    AddPort(a6)
  197. OpenDev:
  198.     lea    inputio(a5),a1        ;struct iostreq
  199.     move.l    d7,14(a1)        ;msg port
  200.     moveq    #0,d0            ;unit=0
  201.     moveq    #0,d1            ;no flags
  202.     lea    inputname(pc),a0    ;device name
  203.     jsr    OpenDevice(a6)
  204.  
  205. ******** set up the new input-handler
  206. AddInputHandler:
  207.     move.l    handler(a5),a0
  208. ;    move.b    #2,LN_TYPE(a0)    ;type: interrupt
  209. ;    move.b    #51,LN_PRI(a0)    ;handler priority
  210.     move    #$0233,LN_TYPE(a0)    ;optimization!
  211.     move.l    handlercode(a5),a1
  212.     move.l    a1,IS_CODE(a0)
  213.  
  214. ; copy the input-handler's code to public memory
  215.     lea    NewHandlerCode(pc),a2
  216.     moveq    #codesize-1,d0
  217. .copy    move.b    (a2)+,(a1)+
  218.     dbf    d0,.copy
  219.  
  220. ; add out new input-handler to the list
  221.     lea    inputio(a5),a1
  222.     move    #9,28(a1)    ;IND_ADDHANDLER
  223.     move.l    a0,40(a1)    ;io_data: Handler addr
  224.     jsr    DoIO(a6)
  225.  
  226. ; close input.device
  227. .closedev
  228.     lea    inputio(a5),a1
  229.     move.l    14(a1),-(sp)
  230.     jsr    CloseDevice(a6)
  231.     move.l    (sp)+,a1
  232.     jsr    RemPort(a6)
  233.  
  234. ******** Hold right mousebutton while booting to disable PAL Window
  235. PAL_Win:
  236.     move    $dff016,d0
  237.     btst    #10,d0       ;test right mouse button
  238.     beq.s    CloseAll
  239.  
  240. ******** Patch OpenWindow() or OpenWindowTagList() (when OS 2.0+)
  241. ; with a new code which will set the initial CLI window
  242. ; with a PAL (256 pixels) Height
  243. Init_PAL_Window:
  244.     moveq    #codesize2,d0
  245.     moveq    #1,d1
  246.     move.l    4.w,a6
  247.     jsr    AllocMem(a6)
  248.     move.l    d0,newvector(a5)
  249.     beq.s    .end
  250.  
  251.     lea    intname(pc),a1
  252.     jsr    OldOpenLibrary(a6)
  253.     move.l    d0,d7
  254. ;    beq.s    .end
  255.     move.l    d0,a1
  256.     move    #OpenWindowTagList,a0
  257.     cmp    #36,20(a1)    ;LIB_VERSION OS 2.0+ ?
  258.     bge.s    .v
  259.     move    #OpenWindow,a0    ;if not, we patch OpenWindow()
  260. .v
  261.     lea    vector(pc),a2
  262.     move    a0,(a2)
  263.     move.l    newvector(a5),d0
  264.     jsr    SetFunction(a6)
  265.     lea    oldvector(pc),a0
  266.     move.l    d0,(a0)
  267.  
  268.     lea    New.Open(pc),a0
  269.     move.l    newvector(a5),a1
  270.     moveq    #codesize2-1,d0
  271. .cop    move.b    (a0)+,(a1)+
  272.     dbf    d0,.cop
  273.  
  274.     move.l    d7,a1
  275.     jsr    CloseLibrary(a6)
  276. .end
  277.  
  278. ******** Close, free & restore all
  279. CloseAll:
  280.     move.l    a5,a1
  281.     move.l    #VARSIZE,d0
  282.     move.l    4.w,a6
  283.     jsr    FreeMem(a6)
  284.  
  285. Restore:
  286.     move.l    $9c(a6),a0    ;execbase->gfxbase
  287.     move.l    38(a0),$80(a4)    ;restore system coplist
  288.     clr    $88(a4)     ;restart system coplist
  289.     move    olddma(a5),$96(a4)    ;restore DMA
  290.  
  291.     movem.l (sp)+,d0-a6
  292.  
  293. ******** Boot up system
  294. Init:
  295.     IFND    DBUG
  296.     lea    dosname(pc),a1
  297.     move.l    #'dos.',(a1)    ;the address of 'dosname' MUST be EVEN !
  298.     jsr    FindResident(a6)
  299.     move.l    d0,a0
  300.     move.l    22(a0),a0
  301.     moveq    #0,d0
  302.     ENDC
  303.     rts
  304.  
  305. put_vbr:
  306.     movec    a4,VBR        ;put the new vbr address
  307.     rte
  308.  
  309. ******** Input-Handler's Code
  310. ; featuring: Mouse Acceleration
  311.  
  312. LSHIFT=1
  313. RSHIFT=2
  314. CONTROL=8
  315. LALT=$10
  316. RALT=$20
  317. LCOMMAND=$40    ;the left Amiga key
  318. RCOMMAND=$80    ;the right one...
  319.  
  320. NewHandlerCode:
  321.     movem.l d0-a6,-(sp)
  322.     move.b    4(a0),d2    ;ie_class
  323.     cmp.b    #2,d2        ;rawmouse?
  324.     beq.b    .mousemov
  325.     cmp.b    #1,d2        ;rawkey?
  326.     bne.b    .no
  327. .key
  328.     moveq    #0,d0
  329.     movem    6(a0),d0-d1    ;ie_code, ie_qualifier
  330.  
  331. * Change here the 'HOTKEY' combination if you need it
  332.     cmp.b    #LALT!LCOMMAND,d1
  333.  
  334.     bne.b    .no
  335.     sub.b    #$50,d0        ;RAWKEY value for F1 key = $50
  336.     bcs.b    .no
  337.     cmp.b    #9,d0        ;F8 is $58
  338.     bhi.b    .no
  339.     lea    xfact(pc),a1
  340.     move    d0,(a1)     ;save new acceleration factor
  341.     bra.b    .no
  342. .mousemov
  343.     movem    10(a0),d0-d1    ;deltaX, deltaY
  344.  
  345. ; roll faster, little mouse!
  346.     move    xfact(pc),d7    ;accel. factor
  347.     muls    d7,d0
  348.     muls    d7,d1
  349.     movem    d0-d1,10(a0)    ;save new values
  350. .no
  351.     movem.l (sp)+,d0-a6
  352.     move.l    a0,d0        ;inputevent en d0
  353.     rts
  354.  
  355. xfact    dc.w    DEFXFACT    ;contains the accel. factor
  356.  
  357. NewHandlerEnd:
  358. codesize=NewHandlerEnd-NewHandlerCode
  359.  
  360. ******** The 'new' OpenWindow() function
  361. New.Open:
  362.     cmp    #256,nw_Height(a0)
  363.     bge.s    .already_max_height
  364.     move    #256,nw_Height(a0)    ;set new window Height
  365. .already_max_height
  366. ;    or.l    #$200,nw_IDCMPFlags(a0)    ;set some new flags
  367. ;    or.l    #8,nw_Flags(a0)
  368.  
  369.     pea    new.title(pc)        ;pointer to new window title
  370.     move.l    (sp)+,nw_Title(a0)    ;set window title
  371. ; The window structure has now been patched,
  372. ; we can restore the old function vector
  373.     movem.l d0-a6,-(sp)
  374.     move.l    a6,a1
  375.     move.l    4.w,a6
  376.     move    vector(pc),a0
  377.     move.l    oldvector(pc),d0
  378.     jsr    SetFunction(a6)
  379.     movem.l (sp)+,d0-a6
  380.  
  381. .jmp    dc.w    $4ef9    ;hex equivalent for a 'jmp' instruction...
  382.  
  383. oldvector    dc.l    0    ;... to the old function address
  384. vector           dc.w    0
  385.  
  386. new.title:    dc.b "AmigaDOS - UtilBoot 1.0 © Frédéric BASSALER",0
  387. codesize2=*-New.Open
  388.  
  389.     even
  390. ******** This is the copperlist, which has to be copied into CHIP memory
  391. LORES=%0001001000000000
  392. HIRES=LORES!$8000
  393. LACE=4
  394.  
  395. RES=LORES    ;this is the resolution (LORES or HIRES), LACEd or not
  396.  
  397. coplist:
  398.  DC.w $0100,RES
  399.  dc.w $0102,$0000
  400.  dc.w $0108,$0000
  401.  dc.w $008E,$2981
  402.  DC.w $0090,$29c1
  403.  IF RES=LORES
  404.  dc.w $0092,$0038
  405.  DC.w $0094,$00d0
  406.  ELSE
  407.  dc.w $0092,$003c
  408.  dc.w $0094,$00d4
  409.  ENDC
  410.  dc.w $00e0        ;ptr to bitplane
  411. hi1:dc.w 0
  412.  dc.w $00e2
  413. lo1:dc.w 0
  414.  dc.w $0180,$777    ;background color
  415.  dc.w $0182,$fff    ;foreground (pen) color
  416.  dc.w $FFFF,$FFFE    ;end of coplist
  417. copsize=*-coplist
  418.  
  419. ******** RAW gfx data
  420. ; first drawn using dpaint, then converted to raw data
  421. rawgfx:
  422.     DC.B    $04,$58,$40,$00,$84,$20,$7C,$0E
  423.     DC.B    $71,$8C,$CC,$87,$70,$00,$9F,$08
  424.     DC.B    $71,$8C,$EC,$50,$9A,$10,$08,$51
  425.     DC.B    $02,$88,$08,$00,$94,$4B,$4A,$52
  426.     DC.B    $84,$50,$A2,$1C,$73,$C8,$9E,$8E
  427.     DC.B    $70,$00,$94,$48,$4A,$52,$84,$50
  428.     DC.B    $9A,$10,$4A,$44,$52,$88,$48,$00
  429.     DC.B    $64,$5C,$71,$8C,$85,$20,$7C,$11
  430.     DC.B    $72,$59,$92,$67,$48,0
  431. rawsize=*-rawgfx
  432.  
  433.     even
  434. intname     dc.b "intuit"
  435. dosname     dc.b "ion.library",0    ;a little trick: how to save 6 bytes!!
  436. inputname    dc.b "input.device",0
  437.  
  438. ; Let's put some info text, so that everybody can see that
  439. ; this wonderful bootblock ain't another fuckin' virus !!!
  440.  
  441.  dc.b "<LMB> TO DISABLE MOUSE_ACCEL, <RMB> TO DISABLE PAL_WINDOW"
  442.  dc.b " HOTKEY: LALT+LCOMMAND+F1..F8 TO CONTROL ACCEL_FACTOR"
  443.  
  444. End:
  445.  
  446. Size=*-Start
  447.  
  448.     IF    Size>1024
  449.     FAIL    Bootblock too big!
  450.     ENDC
  451.  
  452.     dcb.b    1024-Size,0       ;fill the remainder of bootblock with 0's
  453.